﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;


namespace SplenetiX
{
    class Cursor
    {
        private Texture2D fleche, hand;
        private Texture2D pointerTexture;


        private Vector2 mousePosition;

        private MouseState mouseState;




        public Cursor()
        {
        }

        public Texture2D PointerTexture
        {
            get { return pointerTexture; }
            set { pointerTexture = value; }
        }

        public void LoadCursor(ContentManager contentManager)
        {
            fleche = contentManager.Load<Texture2D>("Menu_Interface//cursor_normal");
            hand = contentManager.Load<Texture2D>("Menu_Interface//cursor_click");
        }

        public void UpdateCursor(GraphicsDevice graphics, bool isMouseOver)
        {

            this.mouseState = Mouse.GetState();
            this.mousePosition.X = this.mouseState.X;
            this.mousePosition.Y = this.mouseState.Y;

            // Restrict the Mouse so that it stays inside the current display
            if (this.mousePosition.X < 0)
                this.mousePosition.X = 0;
            if (this.mousePosition.X > graphics.Viewport.Width)
                this.mousePosition.X = graphics.Viewport.Width;
            if (this.mousePosition.Y < 0)
                this.mousePosition.Y = 0;
            if (this.mousePosition.Y > graphics.Viewport.Height)
                this.mousePosition.Y = graphics.Viewport.Height;

            if (isMouseOver)
                pointerTexture = hand;
            else pointerTexture = fleche;

        }

        public void DrawCursor(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(pointerTexture, mousePosition, Color.White);
        }
    }
}
